﻿Imports WeifenLuo.WinFormsUI.Docking
Public Class MainFormDocks

    Const kDockSettingsFile As String = "xml/dock_settings.xml"

    Public Property Deserializer As DeserializeDockContent =
        New DeserializeDockContent(AddressOf GetContentFromPersistantString)

    ' Dock Panels
    Public Property ErrorViewDock As New ErrorViewDock
    Public Property ConsoleOutputDock As New ConsoleOutputDock
    Public Property FileViewDock As New FileViewDock
    Public Property EditorTabDock As New EditorTabDock
    Public Property ClassBrowserDock As New ClassBrowserDock

    Public Sub LoadDockSettings()
        If IO.File.Exists(kDockSettingsFile) Then
            MainForm.DockPanel.LoadFromXml(kDockSettingsFile, Deserializer)
        End If
    End Sub

    Public Sub SaveDockSettings()
        MainForm.DockPanel.SaveAsXml(kDockSettingsFile)
    End Sub

    Public Sub ShowDefaultDocks()
        EditorTabDock.Show(MainForm.DockPanel)
    End Sub

    Public Function GetContentFromPersistantString(ByVal name As String) As DockContent

        If name = ErrorViewDock.GetType().FullName Then
            Return ErrorViewDock
        ElseIf name = FileViewDock.GetType().FullName Then
            Return FileViewDock
        ElseIf name = ClassBrowserDock.GetType().FullName Then
            Return ClassBrowserDock
        ElseIf name = ConsoleOutputDock.GetType().FullName Then
            Return ConsoleOutputDock
        End If

        Return Nothing

    End Function

End Class
